using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
//-----------------------------------------------------------------------------
const string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";

var builder = WebApplication.CreateBuilder(args);
{
  builder.Services.AddCors(options =>
  {
    options.AddPolicy(name: MyAllowSpecificOrigins,
                      builder =>
                        builder.AllowAnyOrigin());
  });
  builder.Services.AddControllers();
  builder.Services.AddSwaggerGen(c =>
    c.SwaggerDoc("v1", new() { Title = "testWebAPI", Version = "v1" }));
}
var app = builder.Build();
{
  // Configure the HTTP request pipeline.
  if (builder.Environment.IsDevelopment())
  {
    app.UseDeveloperExceptionPage();
    app.UseSwagger();
    app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "testWebAPI v1"));
  }
  app.UseCors(MyAllowSpecificOrigins);
  app.MapControllers();
}
app.Run();
